package com.example.minefieldkeepercloud.activity.treatedmachine;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ListView;

import com.example.minefieldkeepercloud.R;
import com.example.minefieldkeepercloud.adapter.TreateMachineAcDetailAdapter;
import com.example.minefieldkeepercloud.bean.TmdBean;
import com.example.minefieldkeepercloud.bean.TreateMachineBean;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class TreateMachineAcDetail extends AppCompatActivity {
    private TreateMachineAcDetailAdapter treateMachineAcDetailAdapter;
    private List<TmdBean> listData;
    @BindView(R.id.recyleview)
    ListView recyleview;
    private TreateMachineBean.DataBean bean;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ac_treatemachinedetail);
        ButterKnife.bind(this);
        InitView();
        getData();
    }

    private void InitView() {
        bean = (TreateMachineBean.DataBean) getIntent().getBundleExtra("bd").getSerializable("data");
        listData = new ArrayList<>();
        treateMachineAcDetailAdapter = new TreateMachineAcDetailAdapter(this, listData);
        recyleview.setAdapter(treateMachineAcDetailAdapter);

    }

    private void getData() {
        if (bean == null) {
            return;
        }

        TmdBean tmdBean=new TmdBean();
        tmdBean.setTitle("IP");
        tmdBean.setKind(0);
        tmdBean.setContent(bean.getIP());
        listData.add(tmdBean);

        TmdBean tmdBean1=new TmdBean();
        tmdBean1.setTitle("报错时间");
        tmdBean1.setKind(0);
        tmdBean1.setContent(bean.getCreatedTime());
        listData.add(tmdBean1);

        TmdBean tmdBean2=new TmdBean();
        tmdBean2.setTitle("异常信息");
        tmdBean2.setKind(1);
        tmdBean2.setContent(bean.getMacErrInfo());
        listData.add(tmdBean2);

        TmdBean tmdBean3=new TmdBean();
        tmdBean3.setTitle("状态");
        tmdBean3.setKind(0);
        tmdBean3.setContent(bean.getMacRunStatus());
        listData.add(tmdBean3);

        TmdBean tmdBean4=new TmdBean();
        tmdBean4.setTitle("矿机标识");
        tmdBean4.setKind(0);
        tmdBean4.setContent(bean.getUniqueID());
        listData.add(tmdBean4);

        TmdBean tmdBean5=new TmdBean();
        tmdBean5.setTitle("矿区名称");
        tmdBean5.setKind(0);
        tmdBean5.setContent(bean.getAreaName());
        listData.add(tmdBean5);

//        TmdBean tmdBean6=new TmdBean();
//        tmdBean6.setTitle("机位");
//        tmdBean6.setKind(0);
//        tmdBean6.setContent(bean.getPlaceName());
//        listData.add(tmdBean6);
//
        TmdBean tmdBean7=new TmdBean();
        tmdBean7.setTitle("客户名称");
        tmdBean7.setKind(0);
        tmdBean7.setContent(bean.getCustomerName());
        listData.add(tmdBean7);

        TmdBean tmdBean8=new TmdBean();
        tmdBean8.setTitle("矿机品牌");
        tmdBean8.setKind(0);
        tmdBean8.setContent(bean.getBrandName());
        listData.add(tmdBean8);

        TmdBean tmdBean9=new TmdBean();
        tmdBean9.setTitle("矿机型号");
        tmdBean9.setKind(0);
        tmdBean9.setContent(bean.getModelName());
        listData.add(tmdBean9);

        TmdBean tmdBean10=new TmdBean();
        tmdBean10.setTitle("实际功率");
        tmdBean10.setKind(0);
        tmdBean10.setContent(bean.getActualPower());
        listData.add(tmdBean10);

        TmdBean tmdBean11=new TmdBean();
        tmdBean11.setTitle("实时算力");
        tmdBean11.setKind(0);
        tmdBean11.setContent(bean.getRealtimeSuanLi());
        listData.add(tmdBean11);

        TmdBean tmdBean12=new TmdBean();
        tmdBean12.setTitle("平均算力");
        tmdBean12.setKind(0);
        tmdBean12.setContent(bean.getAverageSuanLi());
        listData.add(tmdBean12);

        TmdBean tmdBean13=new TmdBean();
        tmdBean13.setTitle("温度");
        tmdBean13.setKind(0);
        tmdBean13.setContent(bean.getTemperature());
        listData.add(tmdBean13);

        TmdBean tmdBean14=new TmdBean();
        tmdBean14.setTitle("风扇转速");
        tmdBean14.setKind(0);
        tmdBean14.setContent(bean.getFanSpeed());
        listData.add(tmdBean14);

        TmdBean tmdBean15=new TmdBean();
        tmdBean15.setTitle("运行时间");
        tmdBean15.setKind(0);
        tmdBean15.setContent(bean.getMonRunTime());
        listData.add(tmdBean15);

        TmdBean tmdBean16=new TmdBean();
        tmdBean16.setTitle("矿机名1");
        tmdBean16.setKind(0);
        tmdBean16.setContent(bean.getMachineName1());
        listData.add(tmdBean16);

        TmdBean tmdBean17=new TmdBean();
        tmdBean17.setTitle("矿池1");
        tmdBean17.setKind(0);
        tmdBean17.setContent(bean.getBitcoinPool1());
        listData.add(tmdBean17);

        TmdBean tmdBean18=new TmdBean();
        tmdBean18.setTitle("矿机名2");
        tmdBean18.setKind(0);
        tmdBean18.setContent(bean.getMachineName2());
        listData.add(tmdBean18);

        TmdBean tmdBean19=new TmdBean();
        tmdBean19.setTitle("矿池2");
        tmdBean19.setKind(0);
        tmdBean19.setContent(bean.getBitcoinPool2());
        listData.add(tmdBean19);

        TmdBean tmdBean20=new TmdBean();
        tmdBean20.setTitle("矿机名3");
        tmdBean20.setKind(0);
        tmdBean20.setContent(bean.getMachineName3());
        listData.add(tmdBean20);

        TmdBean tmdBean21=new TmdBean();
        tmdBean21.setTitle("矿池3");
        tmdBean21.setKind(0);
        tmdBean21.setContent(bean.getBitcoinPool3());
        listData.add(tmdBean21);

        TmdBean tmdBean22=new TmdBean();
        tmdBean22.setTitle("Mac地址");
        tmdBean22.setKind(0);
        tmdBean22.setContent(bean.getMacAddr());
        listData.add(tmdBean22);

        treateMachineAcDetailAdapter.setListData(listData);
        treateMachineAcDetailAdapter.notifyDataSetChanged();
    }

    @OnClick({R.id.title_left})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.title_left:
                finish();
                break;


        }
    }
}
